# when migration do these tasks.
namespace :migration_task do

  desc 'when create advertise_rules run this task'
  task :advertise_rules => :environment do
    [City,Province,TerminalGroup].each do |item|
      item.all.each do |ob|
        ob.send(:create_advertise_rule)
      end
    end
  end

  desc 'init administration group'
  task 'init_administration_group' => :environment do
    group = Group.where(name: "Administration", del: true, category: "Department").first_or_create
    admin = Admin.where(email: "admin@cloudchain.co").first
    UserGroupship.where(user_id: admin.id, group_id: group.id).first_or_create
    Group.where(name: "Global", del: true, category: "Role").first_or_create
  end
end